POV-Ray : Newsgroups : povray.newusers : Olympic Flag : Re: Olympic Flag Server Time
28 Jul 2024 14:24:46 EDT (-0400)
  Re: Olympic Flag  
From: Kenneth
Date: 9 Feb 2009 03:35:01
Message: <web.498fe79fa703dd1f50167bc0@news.povray.org>
"sam kim" <nomail@nomail> wrote:

> I am trying to render an olympic flag by csg
> with torus and an object that can be used for flag.
>
> Which object should I use for flag, or should I throw away the csg
> idea out the window and approach it differently?

Recently, I made a waving flag for animating. It takes a different approach,
using a procedural height_field for the flag itself, then applying an
appropriate image_map to it. (In your case, you could render an image of your
finished flag graphic, then apply it.) The ripples in the flag come from
several bozo patterns, and 'fade in' from left to right (since one side of a
flag is attached to its flag pole, and doesn't wave there.) This is probably
more complex than what you asked for, but it produces a nice result. The code
contains some clock values for animating; just ignore those for rendering a
still image.

Typical flags have a width-to-height ratio of approximately 1.586:1, so I've
used that in the code. There *are* some problems when using pigments to
generate procedural height_fields, but I've left out most of those ugly
details, so that you won't get confused.

Ken W.
--------
#declare flag_function = // to make the undulating flag surface
function{
 pigment{ // a function evaluates its pigment on the X/Y plane.
   gradient x
   pigment_map{
   [0.0 color rgb .5] // .5 is a sort of 'bias' value here, forcing the flag to
                      // line up straight with X
   [0.85
    average
    pigment_map{
         [0.2
         bozo
         scale <595/944,1,1>
         scale 1.1*<.15,.5,1>
         color_map{
             [0.0 rgb 0]
             [1.0 rgb 1]
                  }
         translate 5.5*clock*x // for animating the pattern across the HF
         ]
         [1.0
         bozo
         scale <595/944,1,1>
         scale 1.1*<.35,.4,1>
         color_map{
            [0.0 rgb 0]
            [1.0 rgb 1]
                  }
         translate 2*y // just so it isn't the 'same' bozo pattern repeating.

         translate 5.5*clock*<1,1,0> // for animating the pattern across the
// HF. Because a function imposes a weird 'mirror image' of the pigment
// pattern it is made from, this direction vector--meant to be 45-deg.
// DOWNWARD--is instead made 45-deg. UPWARD.
         ]
        }
     ]
       }
   }
  }

height_field{
 function 944,595{ // actual pixel dimensions of my own image_map...ratio of
                   // 1.586 to 1
         flag_function(x,y,z).gray
                 }
      smooth
      double_illuminate

 texture{
   pigment{
   image_map{jpeg "my_flag_image.jpg" interpolate 2 once} // the once keyword
// is to keep extraneous pixels from showing up at the edges of flag.
   rotate -90*x
   scale <1,1,-1> // to reverse the image_map, due to
                  // HF function weirdness.
   }
  finish{
   ambient .3
   diffuse .8
        }

  normal{ // cloth weave
   average
   normal_map{
   [1.0 gradient x triangle_wave bump_size 1.2 scale .008]
   [1.0 gradient z triangle_wave bump_size 1.2 scale .016]
    }
   }
  }
 scale <944/595,1,1>
 rotate -90*x
 translate 5*y
 }


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.